<?php

namespace app\admin\controller\wechat;

use app\common\controller\Backend;

/**
 * 药品管理
 *
 * @icon fa fa-circle-o
 */
class Accounts extends Backend
{

    /**
     * Keyword模型对象
     */
    protected $model = null;

    public function _initialize()
    {
        parent::_initialize();
        $this->model = new \app\admin\model\wechat\Accounts;
        $this->view->assign("auths", $this->model->getAuths());
        $this->view->assign("accountTypes", $this->model->getAccountTypes());
    }

    public function index()
    {
        if ($this->request->isAjax()) {
            $list = $this->model->select();;
            $total = count($list);
            $result = array("total" => $total, "rows" => $list);

            return json($result);
        }
        return $this->view->fetch();
    }

    public function add($ids = null)
    {

        if ($this->request->isAjax()) {
            $post = input("post.");
            $data = $post['row'];
            $data['uid'] =$this->auth->id;
            $this->model->insertGetId($data);
            $this->success('ok');
        }
        return $this->view->fetch();
    }


}
